#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   统一诊断服务测试_app_test.py
@Time    :   2025/03/20 13:31:28
@Author  :   YangLiang 
@Version :   1.0
@Contact :   yangl@genvict.com
@License :   (C)Copyright 2022-2025
@Desc    :   统一诊断服务测试APP
'''

from pandas._libs import interval
import pytest
import allure
import time
from pytest_assume.plugin import assume
import Set_up
from commDriver.TS_CAN import *
import math


class Test_UnifiedDiagnosticService_APP:
    
    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$01子功能')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$01子功能')
    def test_1001_Default(self, action, Driver):
        """
        在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$01子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        # 步骤1：进入默认会话
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 步骤2：发送$10服务$01子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 步骤3：发送$10服务$01子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 81", "", 0, iStep, False, 'UDS')
        # 步骤4：发送$10服务$01子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDSFun')
        # 步骤5：发送$10服务$01子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 81", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$10服务$03子功能')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$10服务$03子功能')
    def test_1003_Extended(self, action, Driver):
        """
        在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$10服务$03子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 83", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 83", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$10服务$01子功能')
    @allure.description('在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$10服务$01子功能')
    def test_1001_Extended(self, action, Driver):

        """
        在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$10服务$01子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$01子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$01子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$01子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 81", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$01子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 81", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$02子功能')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$02子功能')
    def test_1002_Default(self, action, Driver):
        """
        在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$01子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$02子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$02子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDSFun')
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$82子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 82", "", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$82子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 82", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$03子功能')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$03子功能')
    def test_1003_Default(self, action, Driver):
        """
        在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$10服务$03子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$03子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$03子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDSFun')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$83子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 83", "", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$83子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 83", "", 0, iStep, False, 'UDSFun')

    
    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$10服务$02子功能')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$10服务$02子功能')
    def test_1002_Extended(self, action, Driver):
        """
        在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$10服务$02子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$02子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$02子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDSFun')
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$82子功能 物理寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 82", "", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        # 发送$10服务$02子功能 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 82", "", 0, iStep, False, 'UDSFun')

    
    @allure.severity('critical')
    @allure.title('检查自工具发送预编程条件请求后，预编程状态位保持')
    @allure.description('检查自工具发送预编程条件请求后，预编程状态位保持')
    def test_1002_PreProgramming_Extended(self, action, Driver):
        """
        检查自工具发送预编程条件请求后，预编程状态位保持
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "31 01 02 03", "71 01 02 03", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        time.sleep(4)
        logging.info('等待4秒')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(4)
        logging.info('等待4秒')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        time.sleep(2)
        logging.info('等待2秒')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        time.sleep(1)

    @allure.severity('critical')
    @allure.title('检查自工具发出$10 02 请求后到电控单元进入引导加载程序的时间须在500ms内')
    @allure.description('检查自工具发出$10 02 请求后到电控单元进入引导加载程序的时间须在500ms内')
    def test_into_Bootloader(self, action, Driver):
        """
        检查自工具发出$10 02 请求后到电控单元进入引导加载程序的时间须在500ms内
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        time.sleep(0.4)
        logging.info('等待0.4秒')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 11", "67 11", 0, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('检查自工具发出$10 02 请求后到电控单元进入引导加载程序的时间须在500ms内')
    @allure.description('检查自工具发出$10 02 请求后到电控单元进入引导加载程序的时间须在500ms内')
    def test_into_Bootloader_2(self, action, Driver):
        """
        检查自工具发出$10 02 请求后到电控单元进入引导加载程序的时间须在500ms内
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        time.sleep(0.4)
        logging.info('等待0.4秒')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 84", "62 F1 84", 0, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('检查自工具发出$10 02 请求后,电动单元须在500ms内停止一般网络通讯和网络管理通讯')
    @allure.description('检查自工具发出$10 02 请求后,电动单元须在500ms内停止一般网络通讯和网络管理通讯')
    def test_stopTX_intoBootloader(self, action, Driver):
        """
        检查自工具发出$10 02 请求后,电动单元须在500ms内停止一般网络通讯和网络管理通讯
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 02", "50 02 00 32 01 F4", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 0.1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

    @allure.severity('critical')
    @allure.title('发送未定义的子功能,电控单元须反馈否定应答代码0x12')
    @allure.description('发送未定义的子功能,电控单元须反馈否定应答代码0x12')
    def test_10_NRC12_Default(self, action, Driver):
        """
        检查自工具发送未定义的子功能后，电控单元须反馈否定应答代码0x12
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 10", "7F 10 12", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 10", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$10,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$10,电控单元须反馈否定应答代码0x13')
    def test_10_NRC13_Default(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$10,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "01 10 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 10 13"):
            assert resp[:4] == [0x03, 0x7F, 0x10, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "03 10 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 10 13"):
            assert resp[:4] == [0x03, 0x7F, 0x10, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "04 10 03 00 00 00 00 00", iStep, reqID=0x7DF)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 10 13"):
            assert resp[:4] == [0x03, 0x7F, 0x10, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

    @allure.severity('minor')
    @allure.title('物理寻址扩展会话测试NRC22')
    @allure.description('''验证条件优先级：1. 设置车速>3kph(8kph)2. 发送会话切换请求(0x10 02)3. 预期返回NRC 0x22(条件不满足)4. 重置车速<3kph(2kph)''')
    def test_sessionControl_NRC22_Extended_Phy(self, action, Driver):
        iStep = 1
        # 车速大于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 8)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '10 02', '7F 10 22', 3, iStep, False)
        # 车速小于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)

    @allure.severity('minor')
    @allure.title('物理寻址扩展会话测试NRC22')
    @allure.description('''验证条件优先级：1. 设置车速>3kph(8kph)2. 发送会话切换请求(0x10 02)3. 预期返回NRC 0x22(条件不满足)4. 重置车速<3kph(2kph)''')
    def test_sessionControl_NRC22_Extended_Phy_2(self, action, Driver):
        iStep = 1
        # 车速大于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 2)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31 01 02 03', '71 01 02 03', 3, iStep, False)
        # 车速大于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 8)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '10 02', '7F 10 22', 3, iStep, False)
        # 车速小于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)

    @allure.severity('minor')
    @allure.title('物理寻址扩展会话测试NRC22')
    @allure.description('''验证条件优先级：1. 设置车速>3kph(8kph)2. 发送会话切换请求(0x10 02)3. 预期返回NRC 0x22(条件不满足)4. 重置车速<3kph(2kph)''')
    def test_sessionControl_NRC22_Extended_Phy_3(self, action, Driver):
        iStep = 1
        # 车速大于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 8)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '31 01 02 03', '7F 31 22', 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, '10 02', '7F 10 22', 3, iStep, False)
        # 车速小于3kph
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)


    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$11服务$01子功能')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$11服务$01子功能')
    def test_1101_Default(self, action, Driver):
        """
        在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$11服务$01子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 81", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 81", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$11服务$01子功能')
    @allure.description('在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$11服务$01子功能')
    def test_1101_Extended(self, action, Driver):

        """
        在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$11服务$01子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDSFun')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 81", "", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 81", "", 0, iStep, False, 'UDSFun')


    @allure.severity('critical')
    @allure.title('电控单元在收到电控单元复位请求后，若满足复位条件，须在100ms内进行复位，且复位后进入默认会话')
    @allure.description('电控单元在收到电控单元复位请求后，若满足复位条件，须在100ms内进行复位，且复位后进入默认会话')
    def test_1101_Reset(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 01", "7F 27 7F", 0, iStep, False, 'UDS')


    @allure.severity('critical')
    @allure.title('发送未定义的子功能,电控单元须反馈否定应答代码0x12')
    @allure.description('发送未定义的子功能,电控单元须反馈否定应答代码0x12')
    def test_11_NRC12_Default(self, action, Driver):
        """
        检查自工具发送未定义的子功能后，电控单元须反馈否定应答代码0x12
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 00", "7F 11 12", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 11", "7F 11 12", 0, iStep, False, 'UDS')

       
    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$11,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$11,电控单元须反馈否定应答代码0x13')
    def test_11_NRC13_Default(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$11,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "03 11 01 01 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 11 13"):
            assert resp[:4] == [0x03, 0x7F, 0x11, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "04 11 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 11 13"):
            assert resp[:4] == [0x03, 0x7F, 0x11, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")
        
    @allure.severity('critical')
    @allure.title('物理寻址默认会话下ECU复位NRC22测试')
    @allure.description('验证车速>3kph时复位请求返回NRC22')
    def test_ECUReset_NRC22_Default_Phy(self, action, Driver):
        iStep = 1
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 8)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "11 01", "7F 11 22", 1, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)

    @allure.severity('critical')
    @allure.title('在扩展诊断会话中，电控单元须支持物理寻址的$27服务$01/02子功能')
    @allure.description('在扩展诊断会话中，电控单元须支持物理寻址的$27服务$01/02子功能')
    def test_2701_02_Extended_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "3e 00", "7E 00", 3, iStep, True)

    @allure.severity('critical')
    @allure.title('使用无效密钥进行安全访问请求的次数超出安全访问最大尝试次数，电控单元须激活安全访问延时机制，延时的时间为10s')
    @allure.description('使用无效密钥进行安全访问请求的次数超出安全访问最大尝试次数，电控单元须激活安全访问延时机制，延时的时间为10s')
    def test_2701_02_Extended_InvalidKey(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 35", 0, iStep, False)

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 35", 0, iStep, False)

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 36", 0, iStep, False)

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "7F 27 37", 0, iStep, False)
        logging.info("等待4s")
        time.sleep(3)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False)
        logging.info("等待4s")
        time.sleep(3)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "7F 27 37", 0, iStep, False)
        logging.info("等待2s")
        time.sleep(3)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False)
        iStep = Driver['CAN'].unlock(Driver, iStep)

    
    @allure.severity('critical')
    @allure.title('上电/复位前安全访问请求失败，电控单元须在上电/复位后启动安全访问延时机制，延时的时间为10s')
    @allure.description('上电/复位前安全访问请求失败，电控单元须在上电/复位后启动安全访问延时机制，延时的时间为10s')
    def test_2701_02_Extended_PowerOn_InvalidKey(self, action, Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 35", 0, iStep, False)

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 35", 0, iStep, False)

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 36", 0, iStep, False)

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "7F 27 37", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False)
        logging.info("等待3s")
        time.sleep(3)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03", 0, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "7F 27 37", 0, iStep, False)
        logging.info("等待3s")
        time.sleep(3)
        iStep = Driver['CAN'].unlock(Driver, iStep)



    @allure.severity('critical')
    @allure.title('发送未定义的子功能,电控单元须反馈否定应答代码0x12')
    @allure.description('发送未定义的子功能,电控单元须反馈否定应答代码0x12')
    def test_27_NRC12_Extended(self, action, Driver):
        """
        检查自工具发送未定义的子功能后，电控单元须反馈否定应答代码0x12
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 43", "7F 27 12", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 05", "7F 27 12", 0, iStep, False, 'UDS')
    

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x13')
    def test_27_NRC13_Extended(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "01 27 01 01 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 27 13"):
            assert resp[:4] == [0x03, 0x7F, 0x27, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "03 27 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 27 13"):
            assert resp[:4] == [0x03, 0x7F, 0x27, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "02 27 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 67 01"):
            assert resp[2:4] == [0x67, 0x01], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")
        
        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "01 27 02 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 27 13"):
            assert resp[:4] == [0x03, 0x7F, 0x27, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x24')
    @allure.description('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x24')
    def test_27_NRC24_Extended(self, action, Driver):

        """
        检查自工具发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x24
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 24", 3, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x35')
    @allure.description('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x35')
    def test_27_NRC35_Extended(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x35
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 3, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 02" + "11" * 16, "7F 27 35", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, True, 'UDS')

    
    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x7E')
    @allure.description('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x7E')
    def test_27_NRC7E_Extended(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x7E
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        # boot与APP分开为两个系统，所以是12
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 11", "7F 27 12", 3, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x7F')
    @allure.description('发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x7F')
    def test_27_NRC7F_Default(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$27,电控单元须反馈否定应答代码0x7F
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 01", "7F 27 7F", 1, iStep, False, 'UDS')

    
    # @allure.severity('critical')
    # @allure.title('物理寻址扩展会话下安全访问NRC22测试')
    # @allure.description('验证车速>3kph时安全访问请求返回NRC22')
    # def test_SecurityAccess_NRC22_Extended_Phy(self, action, Driver):
    #     iStep = 1
    #     iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 8)
    #     iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "27 01", "7F 27 22", 3, iStep, False)
    #     iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)

    
    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$28服务$00子功能')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$28服务$00子功能')
    def test_2800_Extended(self, action, Driver):
        """
        在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$28服务$00子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "68 00", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 80 01", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "68 00", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 81 01", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$28服务$03子功能')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$28服务$03子功能')
    def test_2803_Extended(self, action, Driver):
        """
        在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$28服务$03子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDSFun')

    
    @allure.severity('critical')
    @allure.title('在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$28服务$03/83子功能，通讯类型选择$01，检查电控单元能成功的使能或禁止常规报文的发送与接收')
    @allure.description('在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$28服务$03/83子功能，通讯类型选择$01，检查电控单元能成功的使能或禁止常规报文的发送与接收')
    def test_28_stopTX(self, action, Driver):
        """
        在扩展诊断会话中，电控单元须支持物理寻址和功能寻址的$28服务$03/83子功能，通讯类型选择$01，检查电控单元能成功的使能或禁止常规报文的发送与接收
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "68 00", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "68 00", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDSFun')

        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "68 00", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "68 00", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

    @allure.severity('critical')
    @allure.title('已禁止常规通讯报文的接收和发送时，测试使用$10 01需使能常规通讯报文的接收和发送（默认会话下，禁止使用28服务）')
    @allure.description('已禁止常规通讯报文的接收和发送时，测试使用$10 01需使能常规通讯报文的接收和发送（默认会话下，禁止使用28服务）')
    def test_28_stopTX_1001_Start(self, action, Driver):
        """
        已禁止常规通讯报文的接收和发送时，测试使用$10 01需使能常规通讯报文的接收和发送（默认会话下，禁止使用28服务）
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDSFun')

        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

    @allure.severity('critical')
    @allure.title('已禁止常规通讯报文的接收和发送时，测试使用$11 01需使能常规通讯报文的接收和发送（默认会话下，禁止使用28服务）')
    @allure.description('已禁止常规通讯报文的接收和发送时，测试使用$11 01需使能常规通讯报文的接收和发送（默认会话下，禁止使用28服务）')
    def test_28_stopTX_1101_Start(self, action, Driver):
        """
        已禁止常规通讯报文的接收和发送时，测试使用$11 01需使能常规通讯报文的接收和发送（默认会话下，禁止使用28服务）
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDSFun')

        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

    @allure.severity('critical')
    @allure.title('已禁止常规通讯报文的接收和发送时，测试S3server超时电控单元可使能常规通讯报文的接收和发送')
    @allure.description('已禁止常规通讯报文的接收和发送时，测试S3server超时电控单元可使能常规通讯报文的接收和发送')
    def test_28_stopTX_P3Server_Start(self, action, Driver):
        """
        已禁止常规通讯报文的接收和发送时，测试S3server超时电控单元可使能常规通讯报文的接收和发送
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 
        logging.info("等待5s,P3server超时")
        time.sleep(5)
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDS')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        logging.info("等待5s,P3server超时")
        time.sleep(5)
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "68 03", 0, iStep, False, 'UDSFun')

        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}') 

        logging.info("等待5s,P3server超时")
        time.sleep(5)
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDSFun')
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # 0'):
            assert TxMessageCount[0] == 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')  

        logging.info("等待5s,P3server超时")
        time.sleep(5)
        TxMessageCount, iStep = Driver['CAN'].GetTxMessageCount(Driver, iStep, 1)
        with allure.step(f'第{iStep}步:检查发送消息数量 # >0'):
            assert TxMessageCount[0] > 0, logging.error(f'发送消息数量错误, 实际发送消息数量: {TxMessageCount[0]}')

    @allure.severity('critical')
    @allure.title('在扩展诊断会话中，发送诊断请求$28 06 00 检查电控单元须反馈否定应答代码0x12')
    @allure.description('在扩展诊断会话中，发送诊断请求$28 06 00 检查电控单元须反馈否定应答代码0x12')
    def test_28_NRC12_Extended(self, action, Driver):
        """
        在扩展诊断会话中，发送诊断请求$28 06 00 检查电控单元须反馈否定应答代码0x12
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 06 01", "7F 28 12", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 0A 01", "7F 28 12", 0, iStep, False, 'UDS')
    

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$28,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$28,电控单元须反馈否定应答代码0x13')
    def test_28_NRC13_Extended(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$28,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "02 28 00 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 28 13"):
            assert resp[:4] == [0x03, 0x7F, 0x28, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "04 28 00 01 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 28 13"):
            assert resp[:4] == [0x03, 0x7F, 0x28, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

    @allure.severity('critical')
    @allure.title('在扩展诊断会话中，发送诊断请求$28 00 0A 检查电控单元须反馈否定应答代码0x31')
    @allure.description('在扩展诊断会话中，发送诊断请求$28 00 0A 检查电控单元须反馈否定应答代码0x31')
    def test_28_NRC31_Extended(self, action, Driver):
        """
        在扩展诊断会话中，发送诊断请求$28 00 0A 检查电控单元须反馈否定应答代码0x31
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 0A", "7F 28 31", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 00", "7F 28 31", 0, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中,请求28服务,通讯控制服务需支持否定应答代码0x7F')
    @allure.description('在应用程序的默认会话中,请求28服务,通讯控制服务需支持否定应答代码0x7F')
    def test_28_NRC7F_Default(self, action, Driver):
        """
        在应用程序的默认会话中,请求28服务,通讯控制服务需支持否定应答代码0x7F
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "7F 28 7F", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "7F 28 7F", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 80 01", "7F 28 7F", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "7F 28 7F", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 00 01", "", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 03 01", "", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 80 01", "", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "28 83 01", "", 0, iStep, False, 'UDSFun')
        
    @allure.severity('critical')
    @allure.title('物理寻址扩展会话下28服务NRC22测试')
    @allure.description('在物理寻址扩展会话下,车速>3, 请求28服务,通讯控制服务需支持否定应答代码0x22')
    def test_28_NRC22_Extended_Phy(self, action, Driver):
        iStep = 1
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 8)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, "28 00 01", "7F 28 22", 3, iStep, False)
        iStep = Driver['CAN'].SetVehicleSpeed(Driver, iStep, 0)

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$85服务$01子功能')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$85服务$01子功能')
    def test_8501_Extended(self, action, Driver):
        """
        在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$85服务$01子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "C5 01", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 81", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "C5 01", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 81", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$85服务$02子功能')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$85服务$02子功能')
    def test_8502_Extended(self, action, Driver):
        """
        在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$85服务$02子功能
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('验证85服务控制DTC产生与禁止功能')
    @allure.description('验证85服务控制DTC产生与禁止功能')
    def test_85_Enable_DisEnable_Dtc_Extended(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "C5 01", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(2)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(2)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "C5 01", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(2)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(2)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "C5 01", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(2)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(2)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "C5 01", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(2)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 12, 3, iStep)

    
    @allure.severity('critical')
    @allure.title('验证85服务控制禁止DTC功能,会话切换恢复')
    @allure.description('验证85服务控制DTC禁止功能,会话切换恢复')
    def test_85_DisEnable_Dtc_1001(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDSFun')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDSFun')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01", 0, iStep, False, 'UDS')
        time.sleep(3)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 12, 3, iStep)

    @allure.severity('critical')
    @allure.title('验证85服务控制禁止DTC功能,重启恢复')
    @allure.description('验证85服务控制DTC禁止功能,重启恢复')
    def test_85_DisEnable_Dtc_1101(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        time.sleep(4)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        time.sleep(4)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        time.sleep(4)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        time.sleep(4)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

    @allure.severity('critical')
    @allure.title('验证85服务控制禁止DTC功能,P3Server超时恢复')
    @allure.description('验证85服务控制DTC禁止功能,P3Server超时恢复')
    def test_85_DisEnable_Dtc_P3Server(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        logging.info("等待5s,等待P3Server超时")
        time.sleep(9)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        logging.info("等待5s,等待P3Server超时")
        time.sleep(9)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        # 功能寻址
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "C5 02", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        logging.info("等待5s,等待P3Server超时")
        time.sleep(9)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')

        #抑制响应
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 82", "", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        logging.info("等待5s,等待P3Server超时")
        time.sleep(9)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

    @allure.severity('critical')
    @allure.title('在扩展诊断会话中，发送诊断请求$85 03 检查电控单元须反馈否定应答代码0x12')
    @allure.description('在扩展诊断会话中，发送诊断请求$85 03 检查电控单元须反馈否定应答代码0x12')
    def test_85_NRC12_Extended(self, action, Driver):
        """
        在扩展诊断会话中，发送诊断请求$85 03 检查电控单元须反馈否定应答代码0x12
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 03", "7F 85 12", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 00", "7F 85 12", 0, iStep, False, 'UDS')
    

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$85,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$85,电控单元须反馈否定应答代码0x13')
    def test_85_NRC13_Extended(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$85,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "01 85 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 85 13"):
            assert resp[:4] == [0x03, 0x7F, 0x85, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "03 85 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 85 13"):
            assert resp[:4] == [0x03, 0x7F, 0x85, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        
    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中,请求85服务,通讯控制服务需支持否定应答代码0x7F')
    @allure.description('在应用程序的默认会话中,请求85服务,通讯控制服务需支持否定应答代码0x7F')
    def test_85_NRC7F_Default(self, action, Driver):
        """
        在应用程序的默认会话中,请求85服务,通讯控制服务需支持否定应答代码0x7F
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "7F 85 7F", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "7F 85 7F", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 01", "", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "85 02", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$3E服务')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$3E服务')
    def test_3E00_Default(self, action, Driver):
        """
        在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$3E服务
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 80", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 80", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$3E服务')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$3E服务')
    def test_3E80_Extended(self, action, Driver):
        """
        在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$3E服务
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 80", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDSFun')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 80", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在扩展诊断会话下，应用层时间参数S3server时间内，发送测试工具保持连接服务请求，电控单元能够维持在当前会话中')
    @allure.description('在扩展诊断会话下，应用层时间参数S3server时间内，发送测试工具保持连接服务请求，电控单元能够维持在当前会话中')
    def test_3E00_KeepAlive_Extended(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 F4", 0, iStep, False, 'UDS')
        logging.info("等待4s")
        time.sleep(4)
        for i in range(2):
            iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, False, 'UDS')
            logging.info("等待4s")
            time.sleep(4)
            iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 80", "", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "27 01", "67 01", 0, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('在默认会话中，发送诊断请求$3E 01 检查电控单元须反馈否定应答代码0x12')
    @allure.description('在默认会话中，发送诊断请求$3E 01 检查电控单元须反馈否定应答代码0x12')
    def test_3E_NRC12_Default(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 01", "7F 3E 12", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 81", "7F 3E 12", 0, iStep, False, 'UDS')

    
    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$3E,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$3E,电控单元须反馈否定应答代码0x13')
    def test_3E_NRC13_Default(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$3E,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "01 3E 01 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 3E 13"):
            assert resp[:4] == [0x03, 0x7F, 0x3E, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "03 3E 00 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 3E 13"):
            assert resp[:4] == [0x03, 0x7F, 0x3E, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

    
    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$22服务')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$22服务')
    def test_22_Default(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 95", "62 F1 95", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 93", "62 F1 93", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$22服务')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$22服务')
    def test_22_Extended(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 89", "62 F1 89", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 90", "62 F1 90", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$22,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$22,电控单元须反馈否定应答代码0x13')
    def test_22_NRC13_Default(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$22,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "01 22 F1 95 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 22 13"):
            assert resp[:4] == [0x03, 0x7F, 0x22, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "02 22 F1 90 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 22 13"):
            assert resp[:4] == [0x03, 0x7F, 0x22, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "04 22 F1 80 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 22 13"):
            assert resp[:4] == [0x03, 0x7F, 0x22, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$22服务')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$22服务')
    def test_22_NRC31(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F2 89", "7F 22 31", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 FF", "", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC7F')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC7F')
    def test_2E_NRC7F_Default(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')

        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "2E F1 90" + "11" * 17, "7F 2E 7F", 0, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC31')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC31')
    def test_2E_NRC31_Func(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "2E F1 FF", "", 0, iStep, True, 'UDSFun')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务')
    def test_2E_Power_Extended(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "2E F1 90" + Set_up.VINDataIdentifier_hex, "6E F1 90", 0, iStep, True, 'UDS')
        # 断电重启
        iStep = Driver['CAN'].restartETC_Power(Driver, iStep)
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 90", "62 F1 90" + Set_up.VINDataIdentifier_hex, 0, iStep, False, 'UDS')
    
    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务')
    def test_2E_1101_Extended(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "2E F1 90" + Set_up.VINDataIdentifier_hex, "6E F1 90", 0, iStep, True, 'UDS')
        # 重启
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "11 01", "51 01", 0, iStep, False, 'UDS')
        time.sleep(1)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "22 F1 90", "62 F1 90" + Set_up.VINDataIdentifier_hex, 0, iStep, False, 'UDS')


    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$2E,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$2E,电控单元须反馈否定应答代码0x13')
    def test_2E_NRC13_Extended(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "3E 00", "7E 00", 0, iStep, True, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "03 2E F1 90 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 2E 13"):
            assert resp[:4] == [0x03, 0x7F, 0x2E, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "10 0A 2E F1 90 00 00 00", iStep)
        # with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 2E 13"):
        #     assert resp[:4] == [0x03, 0x7F, 0x2E, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")
        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "21 00 00 00 00 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 2E 13"):
            assert resp[:4] == [0x03, 0x7F, 0x2E, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC31')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC31')
    def test_2E_NRC31_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "2E F1 95" + "11" * 21, "7F 2E 31", 0, iStep, True, 'UDS')

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC33')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC33')
    def test_2E_NRC33_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "2E F1 90" + "11" * 17, "7F 2E 33", 0, iStep, False, 'UDS')
    
    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC7F')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$2E服务的NRC7F')
    def test_2E_NRC7F_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "2E F1 90" + "11" * 17, "7F 2E 7F", 0, iStep, False, 'UDS')

    @allure.severity('critical')
    @allure.title('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$14服务')
    @allure.description('在应用程序的默认会话中，电控单元须支持物理寻址和功能寻址的$14服务')
    def test_14_Default(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDSFun')
    
    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$14服务')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$14服务')
    def test_14_Extend(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 03", "50 03 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDSFun')

    @allure.severity('critical')
    @allure.title('读取诊断故障代码，并发送清除诊断故障代码请求，检查目标诊断故障代码被清除')
    @allure.description('读取诊断故障代码，并发送清除诊断故障代码请求，检查目标诊断故障代码被清除')
    def test_14_ClearDtc(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        # 设置电压为8v,生成低压故障
        iStep = Driver['CAN'].SetVolt(Driver, 8.3, 3, iStep)
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09 91 17 16 09", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 FF FF FF", "54", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "19 02 09", "59 02 09", 0, iStep, False, 'UDS')
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1, iStep)

    @allure.severity('critical')
    @allure.title('发送长度不正确的诊断请求$14,电控单元须反馈否定应答代码0x13')
    @allure.description('发送长度不正确的诊断请求$14,电控单元须反馈否定应答代码0x13')
    def test_14_NRC13_Default(self, action, Driver):
        """
        检查自工具发送长度不正确的诊断请求$22,电控单元须反馈否定应答代码0x13
        Args:
            action: 测试动作对象
            Driver: 包含CAN驱动的测试驱动对象
        """
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "01 14 FF FF FF 00 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 14 13"):
            assert resp[:4] == [0x03, 0x7F, 0x14, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

        iStep, resp, _ = Driver['CAN'].Send_And_Receive(Driver, "05 14 FF FF FF FF 00 00", iStep)
        with allure.step(f"第{iStep}步:检查响应消息内容 # 7F 14 13"):
            assert resp[:4] == [0x03, 0x7F, 0x14, 0x13], logging.error(f"响应消息内容错误, 实际响应消息内容: {resp}")

    @allure.severity('critical')
    @allure.title('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$14服务的NRC31')
    @allure.description('在应用程序的扩展会话中，电控单元须支持物理寻址和功能寻址的$14服务的NRC31')
    def test_14_NRC31_Phy(self, action, Driver):
        iStep = 1
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "10 01", "50 01 00 32 01 f4", 0, iStep, False, 'UDS')
        iStep, _, _ = Driver['CAN'].checkReqResp(Driver, "14 AA FF FF", "7F 14 31", 0, iStep, False, 'UDS')

    